import math
def safe_calculator():
    try:
        num1 = float(input("输入第一个数字: "))
        operator = input("运算符 (+, -, *, /, **): ")
        if operator == "**":
            num3 = int(input("请选择：1：求数的幂次，2：求数的平方根："))
            if num3 == 2 :
                return print(num1 ** 0.5)
        num2 = float(input("输入第二个数字: "))
    except ValueError:
        print("错误：请输入有效数字")
        return
    result = None
    if operator == "+":
        result = num1 + num2
    elif operator == "-":
        result = num1 - num2
    elif operator == "*":
        result = num1 * num2
    elif operator == "/":
        try:
            result = num1 / num2
        except ZeroDivisionError:
            print("错误：除数不能为 0")
            return
    elif operator == "**":
        result = num1 ** num2

    else:
        print("错误：无效运算符")
        return
    print(f"结果：{result:.2f}")

safe_calculator()